New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bypass Json string from processing #342
Comments
It sounds like you may be confused about Jackson usage here. If you have a String that contains JSON, do not use Jackson for writing it out -- all Jackson knows is that it is a String, and Strings in JSON must be enclosed in double-quotes, and have their contents escaped. But if you have such a String property as part of your object model, you can use annotation I hope this helps. |
I have converted the json String to JsonNode before passing it back from the below method (after Jackson upgrade to 2.2). But - this used to work in 1.9 version of jackson (example below) and since my upgrade to 2.2 its broken and the way I fixed it is by wrapping the JSON string from another rest call in JsonNode.
|
Could you not just return Question is whether JAX-RS |
That is what I'm returning right now - I changed the signature of the call to be public JsonNode getHealth(@QueryParam("app_id") String app_id) { This rest service is nothing but a wrapper to another internal rest service with key management/security. This is just an example of ping we have many more operations in this API. All I wanted was return back the json string from the rest call - I don't want to create unnecessary POJO's. As I mentioned earlier - it worked perfectly well in 1.9 but in 2.2 I had to wrap the json string with JsonNode and return it back or else jackson adds quotes to json string. |
This should not be the case, unless you are using version 2.0.0 of Jackson's JSON provider, which did have issue: https://github.com/FasterXML/jackson-jaxrs-json-provider/issues/12 JAX-RS provider should consider One more thing to verify, just to rule out version issues: 2.3.0-rc1 is out (and official 2.3.0 in a week or two if all goes well), so would it be possible to try that version? It should be backwards compatible at API level so relatively easy to swap in. |
I tried the latest version of jackson and I have the same issue when using String: "{\n "status" : "Success",\n "pong" : 1\n}" Maven Dependency Tree info : [INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0-rc1:compile If I change the api to return JsonNode, I get what I expect: {"status":"Success","pong":1} |
Ok. That sounds like a bug then. I will need to move this, however, as it is in JAX-RS module. |
I am unfortunately unable to reproduce this, see the new issue. |
I'm experiencing this using JSONPObject. I want to pass a raw json as String but Jackson Provider escapes my String. Is there some way to tell Jackson Provider to not parse JSONPObject content? |
No; JSONPObject functionally only works for output. It might make sense to add a new annotation to indicate "do not parse" for JAX-RS module. If so, it'd be necessary to file an issue for The reason for adding a new annotation (instead of trying to reuse something that would seem useful like |
When getting a valid JSON from database or another rest call and passing it back - jackson adds quotes to the valid json and makes it invalid.Is there any annotation or way to tell jackson that it's valid JSON and to just pass the value back?
The text was updated successfully, but these errors were encountered: